package com.maixy.esdemo.test;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.GetIndexResponse;

import java.io.IOException;

/**
 * @ClassName ESTestIndexSearch
 * @Description TODO
 * @Date 2021/4/16 22:24
 * @Author maixy
 */
public class ESTestIndexSearch {
    public static void main(String[] args) throws IOException {
        RestHighLevelClient esClient =new RestHighLevelClient(
                RestClient.builder(new HttpHost("localhost",9200, "http")));

        //创建索引
        GetIndexRequest request = new GetIndexRequest("user");
        GetIndexResponse response = esClient.indices().get(request, RequestOptions.DEFAULT);
        //响应状态
        System.out.println(response.getAliases());
        System.out.println(response.getMappings());
        System.out.println(response.getSettings());

        esClient.close();
    }
}
